package net.da.core.bof.spi.local;

import net.da.core.bof.SysUser;
import net.da.core.entity.SysUserEntity;
import net.da.core.exception.DaException;

public class SysUserImpl<E extends SysUserEntity> extends PersistentObjectImpl<SysUserEntity> implements SysUser {

    public SysUserImpl() {
        super();
    }

    public SysUserImpl(E entity) {
        super(entity);
    }

    public E getEntity() {
        return (E)super.getEntity();
    }

    public Class getEntityClass() {
        return SysUserEntity.class;
    }

    public boolean isSuperUser() {
        return false;
    }

    public boolean isSystemAdmin() {
        return false;
    }

    public void renameUser(String newName) {
        //TODO: check for the uniqness should be made before renaming
        setName(newName);
    }

    public void setName(String name) {
        getEntity().setName(name);
    }

    public String getName() {
        return getEntity().getName();
    }

//    public void setGroup(Group group) {
//        getEntity().setGroup(((GroupImpl)group).getEntity());
//    }
//
//    public Group getGroup() {
//        return businessObjectManager.getBusinessObjectByEntity(Group.class, getEntity().getGroup());
//    }

    public void setDescription(String description) {
        getEntity().setDescription(description);
    }

    public String getDescription() {
        return getEntity().getDescription();
    }

    public String getPassword() {
        return getEntity().getPassword();
    }

    public void setPassword(String password) {
        getEntity().setPassword(password);
    }

    @Override
    protected void preSaveValidation() throws DaException {
    }

}
